package com.oocl.scan.jdt.parser;

import java.util.Map;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTParser;

public class BaseParser {

  ASTParser astParser;

  public BaseParser() {
    astParser = ASTParser.newParser(AST.JLS8); //设置Java语言规范版本
    astParser.setKind(ASTParser.K_COMPILATION_UNIT);
    Map<String, String> compilerOptions = JavaCore.getOptions();
    compilerOptions.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8); //设置Java语言版本
    compilerOptions.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8);
    compilerOptions.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8);
    astParser.setCompilerOptions(compilerOptions); //设置编译选项
  }
}
